package com.qqin.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
//封装操作结果就像是一个“成绩单”。
public class Result {
    private static final Integer SUCCESS_CODE = 666;//表示成功
    private static final Integer ERROR_CODE = 233;//表示错误

    private Integer code;
    private String msg;
    private Object data;

    public static Result success() {
        return new Result(SUCCESS_CODE, "success", null);
    }

    public static Result success(Object data) {//表示成功

        return new Result(SUCCESS_CODE, "success", data);
    }

    public static Result error(String msg) {//表示错误

        return new Result(ERROR_CODE, msg, null);
    }

}
